<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>绘制文本</title>
</head>
<body>
  <canvas id="ctx" width="1000" height="1000" style="background-color: #eee;"></canvas>
</body>
</html>

<script>
const canvas = document.querySelector('#ctx')
const ctx = canvas.getContext('2d')

var img = new Image();
img.onload = function(){
  ctx.drawImage(img,0,0);
  ctx.beginPath();
  ctx.moveTo(30,96);
  ctx.lineTo(70,66);
  ctx.lineTo(103,76);
  ctx.lineTo(170,15);
  ctx.stroke();
}
img.src = 'https://mdn.mozillademos.org/files/5395/backdrop.png';
</script>